<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="div1">点我绑定事件</div>
<script>
    var addEvent = function( elem, type, handler ){
        if ( window.addEventListener ){
            addEvent = function( elem, type, handler ){
                elem.addEventListener( type, handler, false );
            }
        }else if ( window.attachEvent ){
            addEvent = function( elem, type, handler ){
                elem.attachEvent( 'on' + type, handler );
            }
        }
        addEvent( elem, type, handler );
    };

    var div = document.getElementById( 'div1' );
    addEvent( div, 'click', function(){
        alert (1);
    });
    addEvent( div, 'click', function(){
        alert (2);
    });
</script>

</body>
</html>